package com.minelx.sequence.pattern;

import com.minelx.sequence.core.ReturnMatcher;
import com.minelx.sequence.core.StringScanner;

public class DigitMatcher implements ReturnMatcher<ReturnMatcher<?, StringScanner>, StringScanner> {
	@Override
	public boolean isMatch(StringScanner clue) {
		return clue.exists("[DIGIT]");
	}

	@Override
	public ReturnMatcher<?, StringScanner> onMatched(StringScanner clue) {
		clue.goes("[DIGIT]");
		return ReturnMatcher.create(
				scanner -> scanner.existsIf(Character::isDigit),
				StringScanner::nextChar);
	}
}
